#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
@Project ：zhcx-service-test 
@File    ：listing_template_initialize_service.py
@Author  ：关依林
@Date    ：2023/8/14 17:24 
'''

from testcases.ProductGrading_Strategy.AmazonListing.controller.grading_base_way import *
from testcases.ProductGrading_Strategy.AmazonListing.service.listing_grading_public_way import *
from testcases.ProductGrading_Strategy.public_dispatch_way import getStrategyResult2


class TemplateInitializeVerify:

    def templateDataVerify(self):
        """
        验证思路
        template + sourceId
        1.获取亚马逊所有有效来源渠道id - 验证100个来源渠道
        2.通过模板id获取模板规则
        3.组装基础sql，同一个库的规则字段做参数化
        """
        statTime = time.time()
        cursorListing = connectMysql("Java_strategyListing_Test")
        cursorData = connectMysql("Java_strategyData_Test")
        orderSourceIdList = getCountryOrderSourceId(cursorListing)
        templateCondition = getTemplateCondition(90)
        templateRule,templateRuleValue = getTemplateExecute(templateCondition)

        sourceData = []
        for orderSourceId in orderSourceIdList:
            sourceData = gradingTemplateListingTypeTest(
                templateRule, templateRuleValue, cursorListing, cursorData, orderSourceId
            )
        strategyResult = getStrategyResult2(90,orderSourceIdList[0])
        matchingResult = tuple(set(sourceData) - set(strategyResult))
        matchingResult = tuple(set(strategyResult) - set(sourceData))

        endTime = time.time()
        elapsedTime = round(endTime - statTime, 2)
        print(f"执行时间为：{elapsedTime}")

if __name__ == '__main__':
    TemplateInitializeVerify().templateDataVerify()